package com.example.usermanagement.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Data
@Schema(description = "新增用户请求参数")
public class UserAddRequest {
    @NotBlank(message = "用户名不能为空") // 非空校验
    @Length(min = 4, max = 50, message = "用户名长度必须为4-50位")
    @Schema(description = "用户名", required = true)
    private String username;

    @NotBlank(message = "密码不能为空")
    @Length(min = 6, max = 20, message = "密码长度必须为6-20位")
    @Schema(description = "密码", required = true)
    private String password;

    @Schema(description = "姓名")
    private String fullName;

    @Email(message = "邮箱格式不正确") // 邮箱格式校验
    @Schema(description = "邮箱")
    private String email;

    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "状态：0-禁用，1-正常（默认1）")
    private Integer status = 1; // 关键：设置默认值，避免插入null
}